<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>修改密码</title>
    <link rel="stylesheet" th:href="@{/css/edit.css}"/>
</head>
<body>
<div class="wrapper">
    <h2>修改密码</h2>
    <form action="#" method="post">
        <div class="formList">

            <div class="item itemPwd">
                <label for="userId">用户id:</label>
                <input name="userId" class="disable" id="userId" type="text" th:value="${session.user.userId}" placeholder="用户id" readonly="readonly"
                       autocomplete="off" />
            </div>

            <div class="item itemPwd">
                <label for="userName">用户名:</label>
                <input name="userName" id="userName" type="text" th:value="${session.user.userName}" placeholder="用户名" autocomplete="off" />
            </div>

            <div class="item itemPwd">
                <label for="passWord">密码:</label>
                <input name="passWord" id="passWord" type="text" th:value="${session.user.userPwd}" placeholder="密码" autocomplete="off" />
            </div>

            <div class="item itemPwd">
                <label for="roleId" th:text="${'当前操作用户权限为:'+session.user.roleName}"></label>
                <input type="hidden" name="roleId" id="roleId" th:value="${session.user.roleId}"/>
            </div>


            <button type="button" id="btnUpdate" class="btn">提交</button>
        </div>
    </form>
</div>
</body>
<script th:src="@{/js/jquery/jquery-3.4.1.js}"></script>
<script type="text/javascript">
$("#btnUpdate").on("click",function () {
    $.ajax({
        type: 'POST',
        url:'/updatePassWord' ,
        data: {
            userId: $("#userId").val(),
            userName: $("#userName").val(),
            passWord: $("#passWord").val(),
            roleId: $("#roleId").val()
        }
    }).done(function () {
        window.parent.location.href='http://localhost:8888/';
    }).fail(function () {
        console.log("请求失败!")
    });
})
</script>
</html>